package com.campus_activity.campus_activity.utils;

import cn.dev33.satoken.secure.BCrypt;

public class PasswordUtils {
    /**
     * 输入原始密码，返回加密后的密码
     * @param password
     * @return
     */
    public static String encryptPassword(String password){

        //设置盐值
        String salt = BCrypt.gensalt(10);

        //BCrypt加密
        String pw_hash = BCrypt.hashpw(password, salt);

        return pw_hash;
    }

    /**
     * 判断密码正误
     * @param password  待判断的密码
     * @param realPassword  真实密码
     * @return
     */
    public static boolean confirmPassword(String password, String realPassword){
        return BCrypt.checkpw(password, realPassword);
    }
}
